/**
 *
 * Copyright 2015 RSVP Technologies Inc. All rights reserved.
 * Step.java
 *
 */
package com.gfinal.map.direction;

import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.gfinal.map.place.Location;

/**
 * 路线步骤
 * 
 * @author Gao Yudong (gyd@nbicc.com)
 * @date 2015-2-28
 */
public class Step implements Serializable {
	private static final long serialVersionUID = 369248706612420015L;

	/**
	 * 标示该路段是否在城市内部：0：不在城市内部；1：在城市内部
	 */
	private int area = 0;

	/**
	 * 进入道路的角度 枚举值，返回值在0-11之间的一个值，共12个枚举值，以30度递进，即每个值代表角度范围为30度； 分别代表的含义是：
	 * 0-[345°-15°]； 1-[15°-45°]； 2-[45°-75°]； 3-[75°-105°]； 4-[105°-135°]；
	 * 5-[135°-165°]； 6-[165°-195°]； 7-[195°-225°]； 8-[225°-255°]；
	 * 9-[255°-285°]； 10-[285°-315°]； 11-[315°-345°]
	 */
	private int direction = 0;

	/**
	 * 路段距离，单位：米
	 */
	private int distance = 0;

	/**
	 * 路段耗时,单位：秒
	 */
	private int duration = 0;

	/**
	 * 路段描述
	 */
	private String instructions = null;

	/**
	 * 路段位置坐标描述 如"116.30815169816,40.057096534337"
	 */
	private String path = null;

	/**
	 * 路段等级类别 枚举值，返回在0-9之间的一个值，共10个枚举值
	 * 0-高速公路；1-城市高速路；2-国道；3-省道；4-县道；5-乡镇村道；6-其他道路；7-九级路；8-航线；9-行人道路
	 */
	private int type = 0;

	/**
	 * 路段起点经纬度
	 */
	private Location stepOriginLocation = null;

	/**
	 * 路段终点经纬度
	 */
	private Location stepDestinationLocation = null;

	public Step() {
		super();
	}

	public int getArea() {
		return area;
	}

	public void setArea(int area) {
		this.area = area;
	}

	public int getDirection() {
		return direction;
	}

	public void setDirection(int direction) {
		this.direction = direction;
	}

	public int getDistance() {
		return distance;
	}

	public void setDistance(int distance) {
		this.distance = distance;
	}

	public int getDuration() {
		return duration;
	}

	public void setDuration(int duration) {
		this.duration = duration;
	}

	public String getInstructions() {
		if(instructions != null) {
			String regEx_html = "<[^>]+>";
			Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
			Matcher m_html = p_html.matcher(instructions);
			instructions = m_html.replaceAll("");
		}
		return instructions;
	}

	public void setInstructions(String instructions) {
		this.instructions = instructions;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public Location getStepOriginLocation() {
		return stepOriginLocation;
	}

	public void setStepOriginLocation(Location stepOriginLocation) {
		this.stepOriginLocation = stepOriginLocation;
	}

	public Location getStepDestinationLocation() {
		return stepDestinationLocation;
	}

	public void setStepDestinationLocation(Location stepDestinationLocation) {
		this.stepDestinationLocation = stepDestinationLocation;
	}

	@Override
	public String toString() {
		return "Step [area=" + area + ", direction=" + direction
				+ ", distance=" + distance + ", duration=" + duration
				+ ", instructions=" + getInstructions()  + ", type=" + type + "]";
	}

}
